package com.verlet.springbootdemo.simple.disruptor.netty.server;

import com.verlet.springbootdemo.simple.disruptor.netty.MessageProducer;
import com.verlet.springbootdemo.simple.disruptor.netty.RingBufferWorkPoolFactory;
import com.verlet.springbootdemo.simple.disruptor.netty.TranslatorData;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

import java.util.Random;

/**
 *
 *
 * @author verlet
 * @date 2020/8/17
 */
@Slf4j
public class ServerHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        TranslatorData translatorData = (TranslatorData) msg;
        MessageProducer messageProducer = RingBufferWorkPoolFactory.getInstance().getMessageProducer("code:serverId:server:0");
        messageProducer.onData(translatorData,ctx);
    }
}
